//Popup action
function ctrlInitArrowCreatePopupAction(context, selector, data ){
	var win = window;//(window.parent)?window.parent:window;
	
	$(".ctrl-action-type-create-popup", context).click( function(){
		var tempReloadHadler = win.Page.reloadHandler;
		var rel = $(this).attr("rel");
		var link = $(this);
		var settings = {};
		settings.url = $(this).attr("href") ;
	
		if( rel && rel.indexOf("|")!= -1 ){
			var tmp = rel.split("|");
			settings.width = tmp[0];
			settings.height = tmp[1];
			if(tmp[2] != ""){
				win.Page.reloadHandler = function(force){ CtrlAjax.reload(link)};
				settings.endRemove = function(elts, settings){
					win.Page.reloadHandler = tempReloadHadler;
				};
			}
			
			if( $(this).attr("target") == "_blank" ){
				settings.forceType = "iframe";
				settings.url += "&iframe=" ;
			}else{
				settings.endShowContent = function(elts, settings){
					win.Page.parseHtml(elts.content);
				};
			}
			
			/*var add_data = "" ;
			if( data.length > 0 ) {
				for( var i = 0; i < data.length; ++i ) {
					var pp = data[i].split(":");
					add_data += "&data[" + pp[0] + "]=" + pp[1] ;
				}
			}*/
			
			if( tmp[3] != undefined && tmp[3] != "" ) {
				
				var add_data = "";
				for( var i = 4 ; i < tmp.length ; ++i ) {
					if( tmp[i] != "" ) {
						var pp = tmp[i].split(":");
						add_data += "&data[" + pp[0] + "]=" + pp[1] ;
					}
				}
				
				$.ajax({
					   type: "post",
					   url: ArrowDataConnector.actionObjectUrl,
					   data: 'action=create_tmp&model=' + tmp[3] + add_data,
					   success: function(json){
							ArrowResponseReader.read({
								response: json,
								successCallback: function( result ){
									settings.url += '&id=' + json.singleResponse;
									$.nyroModalManual(settings);
								}
							} );
							
							return false;
							
					   },
				 	   dataType: "json"
				});	
			} 
		} 
		
		return false;
		
	});
	
}